<!-- include tpl=head_lay nopadding=true -->
<script type="text/javascript">
var input_id = "#{$id}";
var multi = {$multi ? "1" : "0"};
var obj = $.dialog.opener;
function show_list()
{
	cid = $.dialog.data('phpok_user_{$id}');
	if(cid == "undefined" || cid == "0" || cid == ""){
		return false;
	}
	$("li[name=list]").show();
	var url = get_url("inp","","type=user&content="+$.str.encode(cid));
	$.phpok.json(url,function(data){
		if(data.status){
			var lst = data.info;
			var c = "";
			for(var i in lst){
				c += '<li id="user_{$id}_'+lst[i]['id']+'">';
				c += '<div class="layui-btn-group">';
				c += '<input type="button" value="'+lst[i]['user']+'" class="layui-btn layui-btn-xs" />';
				c += '<input type="button" value="×" title="删除会员：'+lst[i]['user']+'" onclick="delete_input(\''+lst[i]['id']+'\')" class="layui-btn layui-btn-xs layui-btn-danger" /></div>';
				c += '</li>';
				$("#user_"+lst[i]['id']).hide();
			}
			$("#selected_list").html(c).show();
			$.dialog.data("phpok_user_{$id}",cid);
			return true;
		}
		$("#selected_list").hide();
		$.dialog.removeData("phpok_user_{$id}");
	});
}
function add_input(val)
{
	if(multi){
		var old_c = $.dialog.data('phpok_user_{$id}');
		var c = (old_c && old_c != 'undefined') ? old_c+","+val : val;
		var lst = c.split(",");
		lst = $.unique(lst);
		$.dialog.data('phpok_user_{$id}',lst.join(","));
		show_list();
	}else{
		obj.$("#{$id}").val(val);
		obj.action_{$id}_show();
		$.dialog.removeData("phpok_user_{$id}");
		$.dialog.close();
	}
}
function delete_input(val)
{
	if(multi){
		var old_c = $.dialog.data('phpok_user_{$id}');
		if(!old_c){
			return true;
		}
		var lst = old_c.split(",");
		var n_list = new Array();
		var m=0;
		for(var i=0;i<lst.length;i++){
			if(lst[i] != val){
				n_list[m] = lst[i];
				m++;
			}
		}
		if(n_list.length<1){
			$.dialog.removeData("phpok_user_{$id}");
		}else{
			var str = n_list.join(",");
			$.dialog.data("phpok_user_{$id}",str);
		}
	}else{
		$.dialog.removeData("phpok_user_{$id}");
	}
	show_list();
}
$(document).ready(function(){
	if(multi == 1){
		var new_c = $.dialog.data("phpok_user_{$id}");
		if(!new_c || new_c == "undefined"){
			new_c = obj.$(input_id).val();
		}
		show_list();
	}
});
</script>

<div class="layui-card">
	<div class="layui-card-header">
		<form method="post" action="{url ctrl=open func=user id=$id/}">
		<ul class="layout" style="padding-top:2px;">
			<li><input type="text" class="layui-input" name="keywords" id="keywords" value="{$keywords}" /></li>
			<li><input type="submit" value="搜索" class="layui-btn" /></li>
		</ul>
		</form>
	</div>
	<div class="layui-card-body">
		<!-- if $multi -->
		<div class="list">
			<ul class="layout">
				<li>已选择：</li>
				<div id="selected_list"></div>
				<div class="clear"></div>
			</ul>
		</div>
		<!-- /if -->
		<table width="100%" class="layui-table" lay-size="sm">
		<thead>
		<tr>
			<th style="text-align:center;">ID</th>
			<th width="20px">&nbsp;</th>
			<th width="35px"></th>
			<th class="lft">{lang会员账号}</th>
			<th width="120px">{lang注册时间}</th>
			<th></th>
		</tr>
		</thead>
		<!-- loop from=$rslist key=$key value=$value id=$tmpid -->
		<tr>
			<td align="center">{$value.id}</td>
			<td><span class="status{$value.status}" value="{$value.status}"></span></td>
			<td align="center"><img src="{$value.avatar ? $value.avatar : 'images/user_default.png'}" border="0" width="24px" height="24px" /></td>
			<td align="left">{$value.user}</td>
			<td>{func date 'Y-m-d H:i' $value.regtime}</td>
			<td><input type="button" value="选择" onclick="add_input('{$value.id}')" class="layui-btn layui-btn-xs" /></td>
		</tr>
		<!-- /if -->
		</table>
		<!-- include tpl=pagelist -->
	</div>
</div>
<!-- include tpl=foot_lay is_open=true -->